var itemId="";
var quantityPlusMinus = "null";
var weightNew = "null";
 function setWeight(weightItem)
 {
     weightNew=weightItem.id;
 }
 function setIceCreamItemId(item,waiterVar,tableVar,tablePartVar)
 {
    
    itemIdVar = (item.id);
    var waiterVar = waiterVar;
    var tableVar = tableVar;
    var tablePartVar = tablePartVar;
    var dataString = 'itemIdVar='+ itemIdVar  + '&waiterVar='+ waiterVar + '&tableVar=' + tableVar + '&tablePartVar=' + tablePartVar+ '&weight=' +weightNew;
    $.ajax({
      url:'setIceCreamAjax.php',
      dataType:'HTML',
      data: dataString,
      type:'POST',

      success:function(msg)
      {
        $('.rightable').html(msg);
        weightNew = "null";
      }
    });

 }
 function setQuntityPlusMinus(minusOrPlus)
 {
   quantityPlusMinus = minusOrPlus.id;
    if(quantityPlusMinus == "minus")
    {
      $('#minus').css("background-color","red");
      $('#plus').css("background-color","#B3AFAF");
    }
    if(quantityPlusMinus == "plus")
    {
      $('#minus').css("background-color","#B3AFAF");
      $('#plus').css("background-color","red");
    }
   
 }
function setItemId(item,waiterVar,tableVar,tablePartVar)
{
  itemIdVar = (item.id);
  var waiterVar = waiterVar;
  var tableVar = tableVar;
  var tablePartVar = tablePartVar;
  var dataString = 'itemIdVar='+ itemIdVar  + '&waiterVar='+ waiterVar + '&tableVar=' + tableVar + '&tablePartVar=' + tablePartVar;
  $.ajax({
    url:'setItemAjax.php',
    dataType:'HTML',
    data: dataString,
    type:'POST',
  	      
    success:function(msg)
    {
     
      $('.rightable').html(msg);
      
    }
  });
}
function addQuantity(quantity,waiterVar,tableVar,tablePartVar)
{
  var quantity    = quantity.value;
  var waiter      = waiterVar;
  var table       = tableVar;
  var tableaPart  = tablePartVar;
  var itemId      = itemIdVar;
  var plusOrMinus = quantityPlusMinus;
  var dataString  = 'quantity=' + quantity + '&itemIdVar='+ itemId  + '&waiterVar='+ waiterVar + '&tableVar=' + tableVar + '&tablePartVar=' + tablePartVar + '&plusOrMinusVar=' + plusOrMinus ;
  $.ajax({
    url:'addQuntityAjax.php',
    dataType:'HTML',
    data:dataString,
    type:'POST',
    success:function(msg)
    {
      $('.rightable').html(msg);
      quantityPlusMinus = "null";
      $('#plus').css("background-color","#B3AFAF");
      $('#minus').css("background-color","#B3AFAF");
    }
  });
}

function changeUrlTable(waiterExp,tableNoExp,tablePartExp)
{
  	window.location.href="window8.php?waiter="+waiterExp+"&table="+tableNoExp+"&tablePart="+tablePartExp; 
}
function changeUrlWaiter(waiterExp,tableNoExp,tablePartExp)
{
  	window.location.href="window8.php?waiter="+waiterExp+"&table="+tableNoExp+"&tablePart="+tablePartExp; 
}

$(document).ready(function(){

  if(quantityPlusMinus == "plus")
  {
    $('#plus').css("background-color","red");
  }
  $(".items").click(function(){
    $("#box2").show();
    $(".items").bind('click', function (e) {
      $("#box2").css("left", e.pageX);
      $("#box2").css("top", e.pageY);
    });  
  });
  $('#close').click(function(){
    $("#box2").hide();
  });
  $('.btnWithout').click(function(){
    $('.with').hide();
    $('.without').show();
    $('.btnWithout').css("background-color","red");
    $('.btnWith').css("background-color","white");
  });
  $('.btnWith').click(function(){
    $('.with').show();
    $('.without').hide();
    $('.btnWith').css("background-color","red");
    $('.btnWithout').css("background-color","white");
  });
});